<template>
    <div class="nav-item"
         @click="changeTabIndex(index)">
        {{item|replaceNumToChs}}
    </div>
</template>

<script>
    import {mapMutations} from 'vuex';
    import {replaceNumToChs} from '@/filters'

    export default {
        name: "NavItem",
        props: {
            item: {
                type: String
            },
            index: {
                type: Number
            }
        },
        filters: {
            replaceNumToChs
        },
        methods: {
            ...mapMutations(['changeTabIndex'])
        }
    }
</script>

<style scoped>
    .nav-item {
        float: left;
        width: 25%;
        height: 50px;
        line-height: 50px;
        text-align: center;
    }

    .nav-item.nav-current {
        background: #000;
        color: #fff;
    }
</style>